package com.hitrust.gs.action;

import java.util.HashMap;

import com.hitrust.gs.bean.GSOperatorBean;
import com.hitrust.gs.bean.GSOrderDetailBean;
import com.hitrust.gs.business.GSOrderDeptInfoProcessor;
import com.hitrust.gs.business.GSOrderProcessor;
import com.hitrust.gs.form.GSUnBalanceDetlModSaveForm;
import com.hitrust.gs.lib.GSBaseConstants;
import com.hitrust.gs.service.GSBaseAction;
import com.hitrust.gs.service.GSBaseForm;

public class GSUnBalanceDetailModifyCofirmAction extends GSBaseAction {

	public String execute(GSBaseForm aForm) throws Exception {

        //取得待保存信息
		GSUnBalanceDetlModSaveForm tForm = (GSUnBalanceDetlModSaveForm)aForm;
        try{
            GSOrderDetailBean tOrderDetailBean = new GSOrderDetailBean();
            tOrderDetailBean.setGs_order_detail_id(tForm.getCurOrderDetailId());
            tOrderDetailBean.setGs_order_temp_id(tForm.getCurOrderId());
            tOrderDetailBean.setGs_deliver_goods_id(tForm.getDevGoodsOrderId());
            tOrderDetailBean.setGs_signin_person(tForm.getSigner());
            tOrderDetailBean.setGs_signin_count(tForm.getSignCount());
            tOrderDetailBean.setGs_signin_date(tForm.getSignDate());
            tOrderDetailBean.setGs_goods_unitprice(tForm.getGoodsUnitprice());
            tOrderDetailBean.setGs_deliveryman(tForm.getContactPerson());
            tOrderDetailBean.setGs_deliver_goods_phone(tForm.getContactPhone());
            
            //取得当前操作员信息
            GSOperatorBean tOper = (GSOperatorBean)tForm.getSession().getAttribute(GSBaseConstants.LOGIN);
            tOrderDetailBean.setGs_lastmodifer_id(tOper.getGs_oper_id());
            GSOrderProcessor tOrderProc = new GSOrderProcessor();
            //调用保存签收信息操作
            boolean tFlag = tOrderProc.saveUnBalanceModSignInfoOfNonFlat(tOrderDetailBean,tForm.getBalanceYM(),tForm.getDeptId(),tForm.getIsmanustate());
            if(tFlag){
                tForm.getRequest().setAttribute("message","编号为" + tOrderDetailBean.getGs_order_detail_id()+"的订单明细签收信息调整保存成功!");
            }else{
                tForm.getRequest().setAttribute("message","编号为" + tOrderDetailBean.getGs_order_detail_id()+"的订单明细签收信息调整保存失败!");
            }
            tForm.getRequest().setAttribute("requery","true");
            tForm.getRequest().setAttribute("window","true");//为出现异常准备参数
            
            //取得当前操作员可查询的订货单位和送货地址
            GSOperatorBean tOperBean = (GSOperatorBean)aForm.getSession().getAttribute(GSBaseConstants.LOGIN);
            GSOrderDeptInfoProcessor tProc = new GSOrderDeptInfoProcessor();
            HashMap tMap = tProc.getOrderDeptInfoOfBusOper(tOperBean.getGs_oper_org_id());
            aForm.getRequest().setAttribute("orderdept",tMap);
            
            tForm.getRequest().setAttribute("deptCategory",tForm.getDeptCatgry());
            tForm.getRequest().setAttribute("deptId",tForm.getDeptId());
            tForm.getRequest().setAttribute("balanceYM",tForm.getBalanceYM());
        }catch(Exception e){
            tForm.getRequest().setAttribute("window","true");
            throw e;
        }
        return GSBaseConstants.FORWARD_SUCCESS;
	}

}
